package com.example.designpatterns.command.concrete;

import com.example.designpatterns.command.Command;
import com.example.designpatterns.command.receiver.Stereo;

/**
 * StereoOnCommand类 - 音响开启命令
 */
public class StereoOnCommand implements Command {
    private Stereo stereo;
    
    /**
     * 创建音响开启命令
     * @param stereo 音响对象
     */
    public StereoOnCommand(Stereo stereo) {
        this.stereo = stereo;
    }
    
    @Override
    public void execute() {
        stereo.turnOn();
    }
    
    @Override
    public boolean undo() {
        stereo.turnOff();
        return true;
    }
    
    @Override
    public String getName() {
        return "打开" + stereo.getLocation() + "的音响";
    }
} 